<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Controller;

/**
 * Description of HotsearchController
 *
 * @author Administrator
 */
class HotsearchController extends BaseController{
    //put your code here
    /*
     * 热门搜索列表
     */
    public function hot_search(){
        $re = M('hot_search')->order("count desc")->select();
        $this->assign('re',$re);
        $this->display();
    }
    /*
     * 删除热门搜索
     */
    public function del_hot(){
        $where['hid'] = I('hid');
        $data = array(
            'val' => 0,
            'str' => '删除失败'
        );
        if($where['hid']){
            $re = M('hot_search')->where($where)->delete();
            if($re){
                $data['val'] = 1;
                $data['str'] = '删除成功';
            }
        }
        $this->ajaxReturn($data);
    }
    /*
     * 修改热搜搜索量
     */
    public function hot_count_up(){
        $data['count'] = I('count');
        $where['hid'] = I('hid');
        $dta = array(
            'val' => 0,
            'str' => '修改错误'
        );
        if($data['count'] != '' && $where['hid']){
            $re = M('hot_search')->where($where)->save($data);
            if($re){
                $dta['val'] = 1;
                $dta['str'] = '修改成功';
            }
        }else{
            $dta['str'] = '缺少数据';
        }
        $this->ajaxReturn($dta);
    }
}
